package a51qindian.com.comprehensive.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import a51qindian.com.comprehensive.R;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author: Li
 * Date: 2017/9/13 0013
 * Description: 任务：已接受
 */

public class TaskAcceptedAdapter extends RecyclerView.Adapter<TaskAcceptedAdapter.TaskAcceptedHolder> {

    private LayoutInflater mInflater;

    public TaskAcceptedAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
    }
    private OnAcceptedOpListener mAcceptedOpListener;

    @Override
    public TaskAcceptedAdapter.TaskAcceptedHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=mInflater.inflate(R.layout.item_task_accepted,parent,false);
        TaskAcceptedHolder holder=new TaskAcceptedHolder(view);
        if (mAcceptedOpListener != null) {
            holder.mTxtCall.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mAcceptedOpListener.onCall("18852996181");
                }
            });
            holder.mTxtFinish.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mAcceptedOpListener.onGoToFinish();
                }
            });
        }
        return holder;
    }

    @Override
    public void onBindViewHolder(TaskAcceptedAdapter.TaskAcceptedHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 10;
    }

    public void setAcceptedOpListener(OnAcceptedOpListener acceptedOpListener) {
        mAcceptedOpListener = acceptedOpListener;
    }

    static class TaskAcceptedHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.txt_call)
        TextView mTxtCall;
        @BindView(R.id.txt_finish)
        TextView mTxtFinish;
        public TaskAcceptedHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }

    public interface OnAcceptedOpListener{
        void onCall(String phone);
        void onGoToFinish();
    }
}
